package com.lyhlmj.oop_client.Frames.PlayFrame.Panels;

import com.lyhlmj.oop_client.Style.Buttons.PlayFrameButton.ConcedeButton;
import com.lyhlmj.oop_client.Style.Buttons.PlayFrameButton.InfoButton;
import com.lyhlmj.oop_client.Threads.GetPlayStatusTask;
import com.lyhlmj.oop_client.Utils.GetScreenSize;

import javax.swing.*;
import java.awt.*;

public class PlayFrameButtonPanels extends JPanel {
    private JFrame frame;
    private Window owner;

    private ConcedeButton concedeButton;
    private InfoButton infoButton;
    //  得到Frame的大小
    int width = GetScreenSize.getFitSize()[0];
    int height = GetScreenSize.getFitSize()[1];

    public PlayFrameButtonPanels(Window owner,JFrame frame) {
        this.owner = owner;
        this.frame = frame;

        this.initialButton();
    }

    public void initialButton(){
        concedeButton = new ConcedeButton("认输");
        concedeButton.setPreferredSize(new Dimension((int)(0.2 * width),(int)(0.02 * width)));
        infoButton = new InfoButton("关于");
        infoButton.setPreferredSize(new Dimension((int)(0.2 * width),(int)(0.02 * width)));

        this.setOpaque(false);
        this.add(concedeButton);
        this.add(infoButton);
    }

    //    添加按钮的点击事件
    public void setButtonFunction() {
        concedeButton.addActionListener(e -> {
            concedeButton.doConcede(frame);
        });
    }
}
